<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function ediplan(id)
{
	$("#cat_id").val(id);
	$.post("/product/ajaxbutton", {"op": "showattr","id":id},
	  function(data){
			if(data !=201){
var str='<br><br><br><table cellpadding="0" width="100%" cellspacing="0" border="0" class="stdtable"><thead><tr><th class="head1" width="10%">属性名称</th><th class="head1" width="10%">录入方式</th><th class="head1" width="10%">可选值列表</th><th class="head1" width="10%">CODE</th><th class="head1" width="10%">操作</th></tr></thead>';
			for(var i=0;i<data.length;i++)
			{
			str += "<tr>";
		str+="<td>"+data[i].attr_name+"</td>";
		if(data[i].attr_input_type==0)
		{
			var text= "单行文本";
		}else{
			var text = "下拉选择";	
		}
        str+="<td>"+text+"</td>";
		str+="<td>"+data[i].attr_values+"</td>";
		str+="<td>"+data[i].attr_values_code+"</td>";
		str+="<td><a href=\"javascript:void(0)\" onClick=\"delone("+data[i].attr_id+",'delattr')\">删除</a>｜<a href=\"javascript:void(0)\" onClick=\"editarrt("+data[i].attr_id+")\"> 编辑</a></td>";
        str+="</tr>";
			}
			str+=" </table>";
			$("#showlist").html(str);
			}else{
					$("#showlist").html('');
			}
	   },"json");	
	
	
  $('#returndataModal').modal('show');

}
function editarrt(id)
{
	$.post("/product/ajaxbutton", {"op": "edit","id":id,"st":"editarrt"},
	  function(data){
			if(data)
			{
				$("#cat_id").val(data.cat_id);
				$("#attr_name").val(data.attr_name);
				$("#attr_values").val(data.attr_values);
				$("#attr_values_code").val(data.attr_values_code);
				if(data.attr_input_type==1)
				{
					radioClicked(1);
					$("#attr_input_type1").attr("checked",'true');	
				}else{
					radioClicked(0);
					$("#attr_input_type0").attr("checked",'true');		
				}
				$("#attr_input_type").val(data.attr_input_type);
				$("#attr_id").val(data.attr_id);
			}
			
		return;
	   },"json");
	$('#returndataModal').modal('show');
}
function addattribute()
{
	$('#addattributeform').modal('show');	
}
/**
 * 点击类型按钮时切换选项的禁用状态
 */
function radioClicked(n)
{
  document.forms['saveattform'].elements["attr_values"].disabled = n > 0 ? false : true;
}
</script>
<title>商品类型</title>
<body class="withvernav">
<div class="bodywrapper"> {{include file='/public/leftmenu.tpl'}}
  <div class="centercontent">
    <div class="pageheader notab">
      <h1 class="pagetitle">商品类型</h1>
      <span class="pagedesc">
      <div class="menulist">
        <ul class="profile_summary">
          <li> <a href="javascript:void(0)" onClick="addattribute()" class=""><span>添加商品类型</span></a></li>
        </ul>
      </div>
      </span>
      <div class="menulist">
        <ul class="profile_summary">
          <li class="current"></li>
        </ul>
      </div>
    </div>
    <!--pageheader-->
    
    <div id="contentwrapper" class="contentwrapper">
      <div id="basicform" class="subcontent">
        <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
          <thead>
            <tr>
              <th class="head1">名称</th>
              <th class="head1">商品名</th>
            </tr>
          </thead>
          <tbody>
          
          {{foreach from=$list item=li key=key}}
          <tr>
            <td class="head1">{{$li.cat_name}}</td>
            <td class="head0"><a href="javascript:void(0)" onClick="ediplan({{$li.cat_id}})"> 添加属性</a>｜编辑｜<a href="javascript:void(0)" onClick="delone({{$li.cat_id}},'delattribute')">移除</a></td>
          </tr>
          {{/foreach}}
            </tbody>
          
        </table>
        <br />
      </div>
      <!--subcontent--> 
      
      <!--subcontent--> 
      
    </div>
    <!--contentwrapper--> 
    
  </div>
  <!-- centercontent --> 
  
</div>

<!-- 模态框（Modal） -->
<form action="/product/ajaxbutton?op=saveattr"  method="post" name="saveattform" id="saveattform"  enctype="multipart/form-data" >
<input type="hidden" name="cat_id" id="cat_id">
<input type="hidden" name="attr_id" id="attr_id">
  <div class="modal fade" id="returndataModal" tabindex="-1" role="dialog" aria-labelledby="returnModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:740px;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" 
               aria-hidden="true">× </button>
          <h4 class="modal-title" id="returnModalLabel"> 添加属性 </h4>
        </div>
        <div class="modal-body">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <th width="150"><label>属性名称</label> </th>
              <td align="left"><input type="text" name="attr_name" id="attr_name" class="_check width400"></td>
            </tr>
             <tr>
              <th><label>该属性值的录入方式</label> </th>
              <td align="left"><input type="radio" name="attr_input_type" id="attr_input_type0" value="0"  checked="true"  onclick="radioClicked(0)"/>
          手工录入          <input type="radio" name="attr_input_type" id="attr_input_type1" value="1"  onclick="radioClicked(1)"/>
          从下面的列表中选择（一行代表一个可选值）        </td>
            </tr>
             <tr>
              <th><label>可选值列表</label> </th>
              <td align="left"><textarea name="attr_values" id="attr_values" cols="30" rows="3"></textarea></td>
            </tr>
            <tr>
              <th><label>对应编码</label> </th>
              <td align="left"><textarea name="attr_values_code" id="attr_values_code" cols="30" rows="3"></textarea></td>
            </tr>
          </table>
           <div id="showlist"></div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal"> 关闭 </button>
            <button type="button" class="btn btn-primary"  onclick="AWSsubmit('saveattform','returndataModal')"> 提交 </button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
  </div>
  <!-- /.modal -->
</form>

<!-- 模态框（Modal）添加商品属性 -->
<form action="/product/ajaxbutton?op=saveattribute"  method="post" name="attributeform" id="attributeform" >
  <div class="modal fade" id="addattributeform" tabindex="-1" role="dialog" aria-labelledby="returnaddattributeform" aria-hidden="true">
    <div class="modal-dialog" style="width:740px;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" 
               aria-hidden="true">× </button>
          <h4 class="modal-title" id="returnaddattributeform"> 添加商品类型 </h4>
        </div>
        <div class="modal-body">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td>类型名称： </td>
              <td align="left"><input type="text" name="name" id="name" required class="width200" value="{{$other}}" placeholder="商品属性名称：如衣服" /></td>
            </tr>
          </table>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal"> 关闭 </button>
            <button type="button" class="btn btn-primary"  onclick="AWSsubmit('attributeform','addattributeform')"> 提交 </button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
  </div>
  <!-- /.modal -->
</form>
</body>
</html>